package cn.changeforyou.analyzer.naming;

import cn.changeforyou.utils.string.StringUtils;
import java.util.function.BiFunction;

/**
 * 命名策略枚举， 也定义了算法
 */
public enum NamingStrategy {

	camelCase((origin, prefix) -> StringUtils.toCamelCase(origin)),
	
	underline((origin, prefix) -> StringUtils.toUnderLine(origin)),
	
	underlineWithStructPrefix((origin, prefix) -> StringUtils.toUnderLineAppendStr(origin, prefix, true)),
	
	simpleNaming((field, tableName) -> StringUtils.toUnderLine(field)),
	
	sqlFieldWithAliasNaming((field, tableName) -> tableName + "." + StringUtils.toUnderLine(field)),
	
	;
	
	private BiFunction<String, String, String> biFunction;
	
	NamingStrategy(BiFunction<String, String, String> biFunction) {
		this.biFunction = biFunction;
	}
	
	public String getName(String origin, String prefix) {
		return biFunction.apply(origin, prefix);
	}
	
}
